﻿﻿<%@ page contentType="text/html;charset=UTF-8" language="java" %>
    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
        <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
            <c:set var="ctx" value="${pageContext.request.contextPath}" />
            <html>

            <head>
                <link rel="stylesheet" href="${ctx}/common/common.css">
                <title>Title</title>
                <link rel="stylesheet" href="${ctx}/common/plugins/layuiadmin/layui/css/layui.css" media="all">
                <link rel="stylesheet" href="${ctx}/common/plugins/layuiadmin/layui/css/modules/layer/default/layer.css"
                    media="all">
                <link rel="stylesheet" href="${ctx}/common/plugins/layuiadmin/style/admin.css" media="all">
                <script src="${ctx}/common/plugins/layuiadmin/layui/layui.js"></script>

            </head>
            <style>
                .layui-layer-dialog {
                    top: 0px
                }

                .layui-layer-msg {
                    position: fixed !important;
                    top: 50% !important;
                }
            </style>

            <body style="height: 100%">
                <form class="layui-form" action="${ctx}/person/savePerson" enctype="multipart/form-data" method="post">
                    <input type="hidden" name="id" value="${person.id}" />
                    <input type="hidden" name="tEId" value="${person.tEId}" />
                    <input type="hidden" id="urlEnterpriseId" value="${param.enterpriseId}" />
                    <input type="hidden" name="creatorId" value="${person.creatorId}" />
                    <input type="hidden" name="creatorName" value="${person.creatorName}" />
                    <input type="hidden" id="oldPhone" value="${person.phone}" />
                    <input type="hidden" id="oldIdcard" value="${person.idcard}" />
                    <div class="layui-form-item layui-col-md5" style="margin-top: 50px">
                        <label class="layui-form-label">人员姓名<span style="color: red">*</span></label>
                        <div class="layui-input-block">
                            <input type="text" name="name" lay-verify="required" value="${person.name}" ${!empty
                                detail?"disabled":"" } lay-verify="required" ${!empty
                                detail?"":"placeholder='请输入人员名称'"} autocomplete=" off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item layui-col-md5">
                        <label class="layui-form-label">联系电话<span style="color: red">*</span></label>
                        <div class="layui-input-block">
                            <input type="text" name="phone" lay-verify="isRepeat" ${!empty detail?"disabled":"" }
                                value="${person.phone}" ${!empty detail?"":"placeholder='请输入联系电话'"} autocomplete=" off"
                                class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item layui-col-md5">
                        <label class="layui-form-label">电子邮箱<span style="color: red">*</span></label>
                        <div class="layui-input-block">
                            <input type="text" name="email" lay-verify="required|email" ${!empty detail?"disabled":"" }
                                value="${person.email}" ${!empty detail?"":"placeholder='请输入电子邮箱'"} autocomplete=" off"
                                class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item layui-col-md5">
                        <label class="layui-form-label">身份证<span style="color: red">*</span></label>
                        <div class="layui-input-block">
                            <input type="text" name="idcard" lay-verify="required|identity" ${!empty
                                detail?"disabled":"" } value="${person.idcard}" ${!empty
                                detail?"":"placeholder='请输入身份证'"} autocomplete=" off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item layui-col-md5">
                        <label class="layui-form-label">入职时间</label>
                        <div class="layui-input-block">
                            <input type="text" name="entryTime" id="entry_time" ${!empty detail?"disabled":"" }
                                lay-verify="" value="<fmt:formatDate value='${person.entryTime}' pattern="
                                yyyy-MM-dd" />" ${!empty detail?"":"placeholder='请选择入职时间'"}
                            autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item layui-col-md5">
                        <label class="layui-form-label">文化程度</label>
                        <div class="layui-input-block">
                            <select name="cultureDegree" ${!empty detail?"disabled":"" }>
                                <option value="">请选择文化程度</option>
                                <c:forEach items="${education}" var="e">
                                    <option value="${e.id }" ${person.cultureDegree eq e.id ? "selected" :""}>
                                        ${e.described}</option>
                                </c:forEach>
                            </select>
                        </div>
                    </div>
                    <div class="layui-form-item layui-col-md5">
                        <label class="layui-form-label">职称</label>
                        <div class="layui-input-block">
                            <select name="jobTitle" ${!empty detail?"disabled":"" }>
                                <option value="">请选择职称</option>
                                <c:forEach items="${titles}" var="e">
                                    <option value="${e.id }" ${person.jobTitle eq e.id ? "selected" :""}>${e.described}
                                    </option>
                                </c:forEach>
                            </select>
                        </div>
                    </div>
                    <div class="layui-form-item layui-col-md5">
                        <label class="layui-form-label">专业</label>
                        <div class="layui-input-block">
                            <select name="major" ${!empty detail?"disabled":"" }>
                                <option value="">请选择专业</option>
                                <c:forEach items="${major}" var="e">
                                    <option value="${e.id }" ${person.major eq e.id ? "selected" :""}>${e.described}
                                    </option>
                                </c:forEach>
                            </select>
                        </div>
                    </div>
                    <div class="layui-form-item  layui-col-md5">
                        <label class="layui-form-label">是否离职</label>
                        <div class="layui-input-block">
                            <input type="radio" lay-filter="is_over" name="isOver" ${person.isOver eq 'on'
                                ?'checked':''} ${!empty detail?'disabled':''} value="on" title="离职">
                            <input type="radio" lay-filter="is_over" name="isOver" ${person.isOver ne 'on'
                                ?'checked':''} ${!empty detail?'disabled':''} value="off" title="在职">
                        </div>
                    </div>
                    <div class="layui-form-item layui-col-md5" style="${person.isOver eq 'on'?'':'display: none'}"
                        id="overDiv">
                        <label class="layui-form-label">离职时间</label>
                        <div class="layui-input-block">
                            <input type="text" name="overTime" ${!empty detail?"disabled":"" } id="over_time"
                                lay-verify="" value="<fmt:formatDate value='${person.overTime}' pattern="
                                yyyy-MM-dd" />" ${!empty detail?"":"placeholder='请选择离职时间'"}
                            autocomplete="off" class="layui-input">
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label">人员性别</label>
                        <div class="layui-input-block">
                            <input type="radio" ${!empty detail?"disabled":"" } ${empty person.sex?"checked":"" }
                                name="sex" ${person.sex eq '男' ?'checked':''} value="男" title="男">
                            <input type="radio" ${!empty detail?"disabled":"" } name="sex" ${person.sex eq '女'
                                ?'checked':''} value="女" title="女">
                        </div>
                    </div>
                    <div class="layui-form-item layui-col-md5">
                        <label class="layui-form-label">职务<span style="color: red">*</span></label>
                        <div class="layui-input-block">
                            <select name="job" lay-verify="required" ${!empty detail?"disabled":"" }>
                                <option value="">请选择职务</option>
                                <c:forEach items="${job}" var="e">
                                    <option value="${e.id }" ${person.job eq e.id ? "selected" :""}>${e.described}
                                    </option>
                                </c:forEach>
                            </select>
                        </div>
                    </div>
                    <div class="layui-form-item  layui-col-md5">
                        <label class="layui-form-label">所属部门<span style="color: red">*</span></label>
                        <div class="layui-input-block">
                            <input type="text" name="dept" lay-type="showTree" ${!empty detail?"disabled":"" }
                                lay-verify="required" class="layui-input dept" id="dept" value="${department.name}"
                                readonly ${!empty detail?"":"placeholder='请选择部门'"}  >
            <input type=" hidden" name="tDId" id="deptId" lay-verify="required" value="${person.tDId}">
                        </div>
                    </div>
                    <div class="layui-form-item layui-col-md12">
                        <label class="layui-form-label">身份证</label>
                        <div class="layui-input-block" id="idCart">
                            <button type="button" class="layui-btn" id="idCartBtn" ${!empty detail?"style='display:none'":"" }>
                                <i class="layui-icon">&#xe67c;</i>上传身份证
                            </button>
                            <blockquote class="layui-elem-quote layui-quote-nm" style="margin-top: 10px;">
                                预览图：
                                <div class="layui-upload-list" id="idCartDemo"
                                    style="display: flex;flex-direction: row;flex-wrap: wrap;width: 100%">
                                    <c:forEach items="${personImgIdCardList}" var="cardimg">
                                        <div id="delDiv" style="display: flex;flex-direction: column;margin-left:10px">
                                            <img style="width: 100px;height: 100px;" src="${ctx}${cardimg.turl}"
                                                class="layui-upload-img">
                                            <button type="button" class="layui-btn layui-btn-sm delImg" value="${cardimg.id}" ${!empty detail?"style='display:none'":"" }>删除</button>
                                        </div>
                                    </c:forEach>
                                </div>
                            </blockquote>
                        </div>
                    </div>
                    <div class="layui-form-item layui-col-md5" id="idCardTimeDiv" ${(personImgIdCardList.size()<=0 ||
                        personImgIdCardList==null) ?"style='display:none'":'' } >
        <label class=" layui-form-label">身份证到期时间</label>
                        <div class="layui-input-block">
                            <c:if test="${personImgIdCardList.size()>0}">
                                <input type="text" name="idCardTime" ${!empty detail?"disabled":"" } id="idCardTime"
                                    readonly
                                    value="<fmt:formatDate value='${personImgIdCardList.get(0).expiryDate}' pattern="
                                    yyyy-MM-dd" />" ${!empty detail?"":"placeholder='请选择身份证到期时间'"}
                                autocomplete="off" class="layui-input">
                                <c:forEach items="${personImgIdCardList}" var="card">
                                    <input type="hidden" name="idCardId" value="${card.id}" />
                                </c:forEach>
                            </c:if>
                            <c:if test="${personImgIdCardList.size()<=0 || personImgIdCardList == null}">
                                <input type="text" name="idCardTime" ${!empty detail?"disabled":"" } id="idCardTime"
                                    readonly value="" ${!empty detail?"":"placeholder='请选择身份证到期时间'"} autocomplete=" off"
                                    class="layui-input">
                            </c:if>
                        </div>
                    </div>
                    <div class="layui-form-item layui-col-md12">
                        <label class="layui-form-label">健康证</label>
                        <div class="layui-input-block" id="healthCertificate">
                            <button type="button" class="layui-btn" id="healthCertificateBtn" ${!empty detail?"style='display:none'":"" }>
                                <i class="layui-icon">&#xe67c;</i>上传健康证
                            </button>
                            <blockquote class="layui-elem-quote layui-quote-nm" style="margin-top: 10px;">
                                预览图：
                                <div class="layui-upload-list" id="healthCertificateDemo"
                                    style="display: flex;flex-direction: row;flex-wrap: wrap;width: 100%">
                                    <c:forEach items="${personImgHealthList}" var="personImg">
                                        <div id="delDiv" style="display: flex;flex-direction: column;margin-left:10px">
                                            <img style="width: 100px;height: 100px;" src="${ctx}${personImg.turl}"
                                                class="layui-upload-img">
                                            <button type="button" class="layui-btn layui-btn-sm delImg" value="${personImg.id}" ${!empty detail?"style='display:none'":"" }>删除</button>
                                        </div>
                                    </c:forEach>
                                </div>
                            </blockquote>
                        </div>
                    </div>
                    <div class="layui-form-item layui-col-md5" id="healthCertificateTimeDiv"
                        ${(personImgHealthList.size()<=0 || personImgHealthList==null) ?"style='display:none'":'' } >
                        <label class=" layui-form-label">健康证到期时间</label>
                        <div class="layui-input-block">
                            <c:if test="${personImgHealthList.size()>0}">
                                <input type="text" name="healthCertificateTime" ${!empty detail?"disabled":"" }
                                    id="healthCertificateTime" readonly
                                    value="<fmt:formatDate value='${personImgHealthList.get(0).expiryDate}' pattern="
                                    yyyy-MM-dd" />" ${!empty detail?"":"placeholder='请选择健康证到期时间'"}
                                autocomplete="off" class="layui-input">
                                <c:forEach items="${personImgHealthList}" var="health">
                                    <input type="hidden" name="healthId" value="${health.id}" />
                                </c:forEach>
                            </c:if>
                            <c:if test="${personImgHealthList.size()<=0  || personImgHealthList == null}">
                                <input type="text" name="healthCertificateTime" ${!empty detail?"disabled":"" }
                                    id="healthCertificateTime" readonly value="" ${!empty
                                    detail?"":"placeholder='请选择健康证到期时间'"}
                       autocomplete=" off" class="layui-input">
                            </c:if>
                        </div>
                    </div>
                    <div class="layui-form-item layui-col-md12">
                        <label class="layui-form-label">化验员资格证</label>
                        <div class="layui-input-block" id="qualificationCertificate">
                            <button type="button" class="layui-btn" id="qualificationCertificateBtn" ${!empty detail?"style='display:none'":"" }>
                                <i class="layui-icon">&#xe67c;</i>上传资格证
                            </button>
                            <blockquote class="layui-elem-quote layui-quote-nm" style="margin-top: 10px;">
                                预览图：
                                <div class="layui-upload-list" id="qualificationCertificateDemo"
                                    style="display: flex;flex-direction: row;flex-wrap: wrap;width: 100%">
                                    <c:forEach items="${personImgQualificationList}" var="qualificationimg">
                                        <div id="delDiv" style="display: flex;flex-direction: column">
                                            <img style="width: 100px;height: 100px;"
                                                src="${ctx}${qualificationimg.turl}" class="layui-upload-img">
                                            <button type="button" class="layui-btn layui-btn-sm delImg" value="${qualificationimg.id}" ${!empty detail?"style='display:none'":"" }>删除</button>
                                        </div>
                                    </c:forEach>
                                </div>
                            </blockquote>
                        </div>
                    </div>
                    <div class="layui-form-item layui-col-md5" id="qualificationCertificateTimeDiv"
                        ${(personImgQualificationList.size()<=0 || personImgQualificationList==null)
                        ?"style='display:none'":'' } >
        <label class=" layui-form-label">化验员资格证到期时间</label>
                        <div class="layui-input-block">
                            <c:if test="${personImgQualificationList.size()>0}">
                                <input type="text" name="qualificationCertificateTime" ${!empty detail?"disabled":"" }
                                    id="qualificationCertificateTime" readonly
                                    value="<fmt:formatDate value='${personImgQualificationList.get(0).expiryDate}' pattern="
                                    yyyy-MM-dd" />" ${!empty detail?"":"placeholder='请选择化验员资格证到期时间'"} autocomplete="off"
                                class="layui-input">
                                <c:forEach items="${personImgQualificationList}" var="qualification">
                                    <input type="hidden" name="qualificationId" value="${qualification.id}" />
                                </c:forEach>
                            </c:if>
                            <c:if test="${personImgQualificationList.size()<=0  || personImgQualificationList == null}">
                                <input type="text" name="qualificationCertificateTime" ${!empty detail?"disabled":"" }
                                    id="qualificationCertificateTime" readonly value="" ${!empty
                                    detail?"":"placeholder='请选择化验员资格证到期时间'"} autocomplete=" off" class="layui-input">
                            </c:if>
                        </div>
                    </div>
                    <c:if test="${!empty detail}">
                        <%--查看的时候显示--%>
                            <div class="layui-form-item layui-col-md5">
                                <label class="layui-form-label">创建时间</label>
                                <div class="layui-input-block">
                                    <input type="text" disabled lay-verify=""
                                        value="<fmt:formatDate value='${person.createTime}' pattern=" yyyy-MM-dd" />"
                                    autocomplete="off"
                                    class="layui-input">
                                </div>
                            </div>
                            <div class="layui-form-item layui-col-md5">
                                <label class="layui-form-label">创建人</label>
                                <div class="layui-input-block">
                                    <input type="text" disabled lay-verify="" value="${person.creatorName}"
                                        autocomplete="off" class="layui-input">
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <div class="layui-input-block">
                                    <button type="button" id="rollback" class="layui-btn layui-btn-primary">返回</button>
                                </div>
                            </div>
                            <script>
                                document.getElementById("rollback").addEventListener("click", function () {
                                    var fromPage = '${param.from}';
                                    if (fromPage === 'personList') {
                                        window.location.href = "${ctx}/person/personPage";
                                    } else {
                                        var enterpriseId = document.getElementById('urlEnterpriseId').value || '${person.tEId}';
                                        if (enterpriseId && enterpriseId !== '') {
                                            window.location.href = "${ctx}/supervise/enterprise/queryPersonList?enterpriseId=" + enterpriseId;
                                        } else {
                                            layer.msg('无法获取企业ID，请从企业人员列表进入', { icon: 5 });
                                        }
                                    }
                                })
                            </script>
                    </c:if>
                    <c:if test="${empty detail}">
                        <div class="layui-form-item">
                            <div class="layui-input-block">
                                <button class="layui-btn" id="formBtn" lay-submit lay-filter="formDemo">立即提交</button>
                                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                                <button type="button" id="rollback" class="layui-btn layui-btn-primary">返回</button>
                            </div>
                        </div>
                    </c:if>
                </form>
                <script>
                    if ('${person.isOver}' == 'on') {
                        document.getElementById("overDiv").style.display = "block"
                    }

                    layui.use('upload', function () {
                        var $ = layui.$;
                        var upload = layui.upload;
                        var count = 0;
                        //执行实例
                        var idCart = upload.render({
                            elem: '#idCartBtn' //绑定元素
                            , url: '${ctx}/person/uploadImgs'
                            , data: {
                                type: '1'
                            }
                            , bindAction: '#uploadIdCardSubmit'
                            , exts: 'jpg|png'
                            , accept: 'images'
                            , multiple: true
                            , field: "file"
                            , auto: true
                            , done: function (res, index, upload) {
                                var div = $('#idCartDemo').append('<div style="display: flex;flex-direction: column;margin-left:10px"><img style="width: 100px;height: 100px;" src="${ctx}' + res.turl + '"   class="layui-upload-img"><button type="button" class="layui-btn layui-btn-sm demo-delete  delImg" value="' + res.id + '" >删除</button></div>')
                                div.find('.demo-delete').on('click', function () {
                                    var index = layer.load(1, {
                                        shade: [0.1, '#fff'] //0.1透明度的白色背景
                                    });
                                    var imgId = $(this).val();
                                    var obj = $(this);
                                    $.ajax({
                                        url: "${ctx}/person/deleteImg",
                                        data: { imgId: imgId },
                                        method: 'POST',
                                        async: false,
                                        success: function (data) {
                                            layer.close(index);
                                            $(obj).parent().remove();
                                            isShowIdCardTime();

                                        }
                                    });
                                });
                                $("#idCart").append('  <input type="hidden" name="idCardFileId" value="' + res.id + '">');
                                isShowIdCardTime();
                            }
                        });
                        var healthCertificate = upload.render({
                            elem: '#healthCertificateBtn' //绑定元素
                            , url: '${ctx}/person/uploadImgs'
                            , data: {
                                type: '2'
                            }
                            , bindAction: '#uploadHealthCardSubmit'
                            , exts: 'jpg|png'
                            , accept: 'images'
                            , multiple: true
                            , field: "file"
                            , auto: true
                            , done: function (res, index, upload) {
                                var div = $('#healthCertificateDemo').append('<div style="display: flex;flex-direction: column;margin-left:10px"><img style="width: 100px;height: 100px;" src="${ctx}' + res.turl + '"   class="layui-upload-img"><button type="button" class="layui-btn layui-btn-sm demo-delete  delImg" value="' + res.id + '" >删除</button></div>')
                                div.find('.demo-delete').on('click', function () {
                                    var index = layer.load(1, {
                                        shade: [0.1, '#fff'] //0.1透明度的白色背景
                                    });
                                    var imgId = $(this).val();
                                    var obj = $(this);
                                    $.ajax({
                                        url: "${ctx}/person/deleteImg",
                                        data: { imgId: imgId },
                                        method: 'POST',
                                        async: false,
                                        success: function (data) {
                                            layer.close(index);
                                            $(obj).parent().remove();

                                            isShowHealthTime();

                                        }
                                    });
                                });
                                $("#healthCertificate").append('  <input type="hidden" name="healthCertificateFileId" value="' + res.id + '">');
                                isShowHealthTime();
                            }
                        });
                        var qualificationCertificate = upload.render({
                            elem: '#qualificationCertificateBtn' //绑定元素
                            , url: '${ctx}/person/uploadImgs'
                            , data: {
                                type: '3'
                            }
                            , bindAction: '#uploadQualificationCardSubmit'
                            , exts: 'jpg|png'
                            , accept: 'images'
                            , multiple: true
                            , field: "file"
                            , auto: true
                            , done: function (res, index, upload) {
                                var div = $('#qualificationCertificateDemo').append('<div style="display: flex;flex-direction: column;margin-left:10px"><img style="width: 100px;height: 100px;" src="${ctx}' + res.turl + '"   class="layui-upload-img"><button type="button" class="layui-btn layui-btn-sm demo-delete  delImg" value="' + res.id + '" >删除</button></div>')
                                div.find('.demo-delete').on('click', function () {
                                    var index = layer.load(1, {
                                        shade: [0.1, '#fff'] //0.1透明度的白色背景
                                    });
                                    var imgId = $(this).val();
                                    var obj = $(this);
                                    $.ajax({
                                        url: "${ctx}/person/deleteImg",
                                        data: { imgId: imgId },
                                        method: 'POST',
                                        async: false,
                                        success: function (data) {
                                            layer.close(index);
                                            $(obj).parent().remove();
                                            isShowQualificationTime();
                                        }
                                    });
                                });
                                $("#qualificationCertificate").append('  <input type="hidden" name="qualificationCertificateFileId" value="' + res.id + '">');
                                isShowQualificationTime();
                            }
                        });
                        $('.delImg').on("click", function () {
                            var index = layer.load(1, {
                                shade: [0.1, '#fff'] //0.1透明度的白色背景
                            });
                            var imgId = $(this).val();
                            var obj = $(this);
                            $.ajax({
                                url: "${ctx}/person/deleteImg",
                                data: { imgId: imgId },
                                method: 'POST',
                                async: false,
                                success: function (data) {
                                    layer.close(index);
                                    $(obj).parent().remove();
                                    isShowIdCardTime();
                                    isShowHealthTime();
                                    isShowQualificationTime();
                                }
                            });
                        });

                        function isShowIdCardTime() {
                            console.log($("#idCart").find("img").length)
                            if ($("#idCart").find("img").length > 0) {
                                $("#idCardTimeDiv").show();
                            } else {
                                $("#idCardTimeDiv").hide();
                            }
                        }
                        function isShowHealthTime() {
                            if ($("#healthCertificate").find("img").length > 0) {
                                $("#healthCertificateTimeDiv").show();
                            } else {
                                $("#healthCertificateTimeDiv").hide();
                            }
                        }
                        function isShowQualificationTime() {
                            if ($("#qualificationCertificate").find("img").length > 0) {
                                $("#qualificationCertificateTimeDiv").show();
                            } else {
                                $("#qualificationCertificateTimeDiv").hide();
                            }
                        }

                    });


                    //Demo
                    layui.use('form', function () {
                        var $ = layui.$;
                        var form = layui.form;
                        //监听提交
                        form.on('submit(formDemo)', function (data) {
                            layer.load(1, {
                                shade: [0.1, '#fff'] //0.1透明度的白色背景
                            });
                        });
                        form.verify({
                            identity: function (value, item) {
                                var reg18 = /^[1-9]\d{5}(18|19|([23]\d))\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/;
                                var reg15 = /^[1-9]\d{5}\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{2}$/;
                                if (reg18.test(value) === false && reg15.test(value) === false) {
                                    return "身份证输入不合法";
                                }
                                if ($("#oldIdcard").val() != value) {
                                    var isSubmit = true;
                                    $.ajax({
                                        url: "${ctx}/person/checkIdcard",
                                        data: { checkIdcard: value }, //请求的附加参数，用json对象
                                        method: 'POST',
                                        async: false,
                                        success: function (data) {
                                            if (data == '0') {
                                                isSubmit = false;
                                            }
                                        }
                                    });
                                    if (isSubmit == false) {
                                        return "身份证已存在";
                                    }
                                }
                            },
                            number: [/^[0-9]*$/, '必须输入数字啊'],
                            isRepeat: function (value, item) { //value：表单的值、item：表单的DOM对象
                                if (value.trim().length <= 0) {
                                    return "必填项不能为空";
                                }
                                var reg = /^1[3|4|5|7|8|9]\d{9}$/
                                if (value.trim().length > 0) {
                                    if (!reg.test(value)) {
                                        return "手机格式不正确";
                                    }
                                }
                                console.log($("#oldPhone").val());
                                if ($("#oldPhone").val() != value) {
                                    var isSubmit = true;
                                    $.ajax({
                                        url: "${ctx}/person/checkPhone",
                                        data: { checkPhone: value }, //请求的附加参数，用json对象
                                        method: 'POST',
                                        async: false,
                                        success: function (data) {
                                            if (data == '0') {
                                                isSubmit = false;
                                            }
                                        }
                                    });
                                    if (isSubmit == false) {
                                        return "联系电话已存在";
                                    }
                                }
                            }
                        });

                        $("#dept").on("click", function () {
                            layer.open({
                                type: 2,
                                title: '部门信息',
                                shadeClose: true,
                                offset: '10px',
                                shade: 0.8,
                                area: ['30%', '80%'],
                                content: '${ctx}/person/queryMyDeptPage' //iframe的url
                            });

                        })
                        form.on('radio(is_over)', function (data) {
                            if (data.value == "on") {
                                $("#overDiv").show();
                                $("input[name='overTime']").val("")
                            } else {
                                $("#overDiv").hide();
                                $("input[name='overTime']").val("")
                            }
                        });
                    });

                    layui.use('laydate', function () {
                        var laydate = layui.laydate;
                        //执行一个laydate实例
                        laydate.render({
                            elem: '#entry_time' //指定元素
                            , type: 'date'
                        });
                        laydate.render({
                            elem: '#over_time' //指定元素
                            , type: 'date'
                        });
                        laydate.render({
                            elem: '#qualificationCertificateTime' //指定元素
                            , type: 'date'
                        });
                        laydate.render({
                            elem: '#healthCertificateTime' //指定元素
                            , type: 'date'
                        });
                        laydate.render({
                            elem: '#idCardTime' //指定元素
                            , type: 'date'
                        });


                    });
                    document.getElementById("rollback").addEventListener("click", function () {
                        var fromPage = '${param.from}';
                        if (fromPage === 'personList') {
                            window.location.href = "${ctx}/person/personPage";
                        } else {
                            var enterpriseId = document.getElementById('urlEnterpriseId').value || '${person.tEId}';
                            if (enterpriseId && enterpriseId !== '') {
                                window.location.href = "${ctx}/supervise/enterprise/queryPersonList?enterpriseId=" + enterpriseId;
                            } else {
                                layer.msg('无法获取企业ID，请从企业人员列表进入', { icon: 5 });
                            }
                        }
                    })

                </script>
            </body>

            </html>